package com.example.swing.jframe1;

import javax.swing.*;
import java.awt.*;
import java.util.concurrent.TimeUnit;

/**
 * 增加一个时间执行队列,向队列提交任务
 */
public class JFrameTestTask3 extends JFrame{
    private JButton
            button1 = new JButton("Button1"),
            button2 = new JButton("Button2");
    public JFrameTestTask3(){
        super("Hello Swing");
        setLayout(new FlowLayout());
        add(button1);
        add(button2);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(500,300);
        setVisible(true);
    }
    static JFrameTestTask3 ssp;
    public static void main(String[] args) throws InterruptedException {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                ssp = new JFrameTestTask3();
            }
        });
        TimeUnit.SECONDS.sleep(3);
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                ssp.button2.setText("button is change");
            }
        });
    }
}
